package com.xiaoxi.exam.service;

import cn.xinzhili.xutils.core.http.Response;
import com.xiaoxi.exam.bean.Grep;
import com.xiaoxi.exam.dao.ExamToeflMapper;
import com.xiaoxi.exam.dao.custom.CustomExamToeflMapper;
import com.xiaoxi.exam.model.ExamToefl;
import com.xiaoxi.exam.model.ExamToeflExample;
import com.xiaoxi.exam.model.ExamToeflExample.Criteria;
import com.xiaoxi.exam.utils.ExamTimeCompartor;
import com.xiaoxi.exam.utils.ToeflExamFactory;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ExamService {

  @Autowired
  private ExamToeflMapper examToeflMapper;

  @Autowired
  private CustomExamToeflMapper customExamToeflMapper;


  public List<ExamToefl> getExamByIds(List<Long> ids) {
    ExamToeflExample examToeflExample = new ExamToeflExample();
    examToeflExample.or().andIdIn(ids).andDeletedAtIsNull();
    return examToeflMapper.selectByExample(examToeflExample);
  }

  public List<String> getExamTimeByCityAndSchool() {
    ExamToeflExample examToeflExample = new ExamToeflExample();
    examToeflExample.setDistinct(true);
    examToeflExample.or().andDeletedAtIsNull();
    List<String> dates = customExamToeflMapper.getExamTime();
    return dates.stream().sorted(new ExamTimeCompartor()).collect(Collectors.toList());
  }
}
